/*
 *   Copyright (c) 2010 Sonrisa Informatikai Kft. All Rights Reserved.
 * 
 *  This software is the confidential and proprietary information of
 *  Sonrisa Informatikai Kft. ("Confidential Information").
 *  You shall not disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Sonrisa.
 * 
 *  SONRISA MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 *  THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 *  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 *  PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SONRISA SHALL NOT BE LIABLE FOR
 *  ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 *  DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

package com.zh.jbet.core.service.impl;

import com.zh.jbet.core.dao.BaseJpaDao;
import com.zh.jbet.core.entity.BaseEntity;
import com.zh.jbet.core.service.EntityService;
import java.util.List;

/**
 *
 * @author sonrisa
 */
public class BaseEntityService<T extends BaseEntity> implements EntityService<T> {
    protected BaseJpaDao<T> entityDao;

    public BaseJpaDao<T> getEntityDao() {
        return entityDao;
    }

    public void setEntityDao(BaseJpaDao<T> entityDao) {
        this.entityDao = entityDao;
    }

    @Override
    public int count(T filterEntity) {
        return entityDao.count(filterEntity);
    }

    @Override
    public List<T> findByFilter(T filterEntity, String sort, int start, int count) {
        return entityDao.find(filterEntity, sort, start, count);
    }

    @Override
    public T save(T entity) {
        return entityDao.save(entity);
    }

    @Override
    public boolean delete(T entity) {
        return entityDao.delete(entity);
    }
    
    @Override
    public T load(Long id) {
        return entityDao.load(id);
    }

    @Override
    public T getDefaultInstance() {
        return entityDao.createNewInstance();
    }
}
